package com.mk.cloud.common.util;

import com.alibaba.fastjson.JSON;
import com.mk.cloud.common.enums.ErrorCode;

import java.util.HashMap;
import java.util.Map;

public class ResUtils {

    public static String OK(Object obj){
        Map<String,Object> result = new HashMap<>();
        result.put("status","0");
        result.put("data",obj);
        return JSON.toJSONString(result);
    }

    public static String OK(){
        Map<String,Object> result = new HashMap<>();
        result.put("status","0");
        return JSON.toJSONString(result);
    }

    public static String FAIL(ErrorCode err){
        Map<String,Object> result = new HashMap<>();
        result.put("status",err.status());
        result.put("data",err.message());
        return JSON.toJSONString(result);
    }
}
